package com.zhaoxi.project.wms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.WmsOrderType;
import com.zhaoxi.project.wms.service.impl.WmsOrderTypeServiceImpl;
import com.zhaoxi.framework.web.controller.BaseController;
import com.zhaoxi.framework.web.domain.AjaxResult;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 产品入库录Controller
 * 
 * @author zhaoxi
 * @date 2023-07-22
 */
@RestController
@RequestMapping("/wms/type")
public class WmsOrderTypeController extends BaseController
{
    @Autowired
    private WmsOrderTypeServiceImpl wmsOrderTypeService;

    /**
     * 查询产品入库录列表
     */
    @PreAuthorize("@ss.hasPermi('wms:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsOrderType wmsOrderType)
    {
        startPage();
        List<WmsOrderType> list = wmsOrderTypeService.selectWmsOrderTypeList(wmsOrderType);
        return getDataTable(list);
    }

    /**
     * 导出产品入库录列表
     */
    @PreAuthorize("@ss.hasPermi('wms:type:export')")
    @Log(title = "产品入库录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsOrderType wmsOrderType)
    {
        List<WmsOrderType> list = wmsOrderTypeService.selectWmsOrderTypeList(wmsOrderType);
        ExcelUtil<WmsOrderType> util = new ExcelUtil<WmsOrderType>(WmsOrderType.class);
        util.exportExcel(response, list, "产品入库录数据");
    }

    /**
     * 获取产品入库录详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsOrderTypeService.selectWmsOrderTypeById(id));
    }

    /**
     * 新增产品入库录
     */
    @PreAuthorize("@ss.hasPermi('wms:type:add')")
    @Log(title = "产品入库录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsOrderType wmsOrderType)
    {
        return toAjax(wmsOrderTypeService.insertWmsOrderType(wmsOrderType));
    }

    /**
     * 修改产品入库录
     */
    @PreAuthorize("@ss.hasPermi('wms:type:edit')")
    @Log(title = "产品入库录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsOrderType wmsOrderType)
    {
        return toAjax(wmsOrderTypeService.updateWmsOrderType(wmsOrderType));
    }

    /**
     * 删除产品入库录
     */
    @PreAuthorize("@ss.hasPermi('wms:type:remove')")
    @Log(title = "产品入库录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsOrderTypeService.deleteWmsOrderTypeByIds(ids));
    }
}
